Re: [SQL] quest:optimization with indexes - Mailing list pgsql-sql

From Herouth Maoz
Subject Re: [SQL] quest:optimization with indexes
Date
Msg-id l03130302b3d727c777c5@[147.233.159.109]
Whole thread Raw
In response to quest:optimization with indexes  (Clayton Cottingham <drfrog@smartt.com>)
Responses Re: [SQL] quest:optimization with indexes  ("Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu>)
List pgsql-sql
At 01:42 +0300 on 11/08/1999, Clayton Cottingham wrote:


> if we put in an index or not an explain say it still does a seq scan,
> same amount of time taken!
>
> ive tried putting the index using just the oid , a combo of some fields
> of our data using btree
>
> where/what rules should be followed for setting up a good indexing
> scheme under pg?

You should put indices on the fields mentioned in your query's WHERE clause.

You should try and avoid using functions on the fields in a WHERE clause.
For example, even if you have an index on the field "surname" in your
table, a query with WHERE upper( surname ) = "SMITH" will not use that
index. You can define indices on the function upper(surname) if this sort
of query is common.

The same goes for operators such as LIKE. LIKE will only use the index if
the expression is anchored to the beginning of the string, as in WHERE
surname LIKE 'Smi%', but not WHERE surname LIKE '%mit%'.

And always keep in mind that adding indices penalizes you on insert and update.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma




pgsql-sql by date:

Previous
From: Clayton Cottingham
Date:
Subject: quest:text search optimizing ala glimpse
Next
From: "Ross J. Reedstrom"
Date:
Subject: Re: [SQL] quest:optimization with indexes